#pragma once
#include <iostream>
#include <string>

using namespace std;

const string opers = "+-*/%";

enum
{
    DIVERROR = 1,
    MODERROR = 2,
    UNKNOWERRROR = 3
};

class Task
{
public:
    Task(int x, int y, char op) : data1_(x), data2_(y), oper_(op), result_(0), exitcode_(0)
    {}

    void run()
    {
        switch (oper_)
        {
        case '+':
            result_ = data1_ + data2_;
            break;
        case '-':
            result_ = data1_ - data2_;
            break;
        case '*':
            result_ = data1_ * data2_;
            break;
        case '/':
            if (data2_ == 0)
                exitcode_ = DIVERROR;
            else
                result_ = data1_ / data2_;
            break;
        case '%':
            if (data2_ == 0)
                exitcode_ = MODERROR;
            else
                result_ = data1_ % data2_;
            break;
        default:
            exitcode_ = UNKNOWERRROR;
            break;
        }
    }

    void operator()()
    {
        run();
    }

    string GetResult()
    {
        string ret = to_string(data1_);
        ret += ' ';
        ret += oper_;
        ret += ' ';
        ret += to_string(data2_);
        ret += ' ';
        ret += '=';
        ret += ' ';
        ret += to_string(result_);
        ret += "[exitcode: ";
        ret += to_string(exitcode_);
        ret += ']';

        return ret;
    }

    string GetTask()
    {
        string ret = to_string(data1_);
        ret += ' ';
        ret += oper_;
        ret += ' ';
        ret += to_string(data2_);
        ret += ' ';
        ret += '=';
        ret += ' ';
        ret += '?';
        return ret;
    }    

    ~Task(){}

private:
    int data1_;
    int data2_;
    char oper_;
    int result_;
    int exitcode_;
};